<%@page import="com.ignou.mca.beans.ExamBean"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.ignou.mca.datasource.DatabaseOperations"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.ignou.mca.beans.UserVO"%><html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="theme/style.css"
	media="screen" />
<title>OES - Exams enrolled by user</title>
<script type="text/javascript">

	function startExam(examId,subjectId)
	{
		window.location.href = 'TermsConditions.jsp?exam='+examId+'&subject='+subjectId;
	}

</script>
</head>
<body>
	<div id="MainWrapper">
		<jsp:include page="header.jsp" /> 
		<jsp:include page="LeftContainer.jsp" />
		<div id="MainContent">
		<center><h2>Exams Enrolled by you</h2></center>
		<%
			UserVO uvo = (UserVO) session.getAttribute("UserVO");
			int subjectID = 0;
			if(uvo==null)
			{
				response.sendRedirect("./Login.jsp");
			}
			else
			{
				String userName = uvo.getUserName();
				DatabaseOperations dbOperations = new DatabaseOperations();
				ArrayList<ExamBean> exams = new ArrayList<ExamBean>();
				exams = dbOperations.getUserEnrolledExams(userName);
				if(exams.size()<1)
				{
					%>
						<center><font color="red">You have not enrolled for any exams.</font></center>
					<%
				}else
				{
					%>
					<table align="center" width="100%" height="100%">	
					<tr>
						<td>Exam Id</td>
						<td>Exam Name</td>
						<td>Exam Duration(mins)</td>
					</tr>
					<tr>
						<td></td>
						<td></td>
						<td></td>
					</tr>
					<%	
						Iterator<ExamBean> itr = exams.iterator(); 
						while(itr.hasNext()) 
						{
							ExamBean eb = (ExamBean)itr.next();	
						%>
						<tr>
							<td><%= eb.getExamId()%></td>
							<td><%= eb.getExamName()%></td>
							<td><%= eb.getDuration()%></td>
							<td><a href='javascript: startExam(<%=eb.getExamId()%>,<%=eb.getSubjectId()%>)'>Start Exam</a></td>
						</tr>
						<%
						}
						%>
					</table>
					<%
				}
			}
					%>
				<br><br><br>
				Click <a href="Home.jsp?">here</a> to go back.<br>
					<!-- Click <a href="AddExam.jsp?subject=<%=subjectID%>">here</a> to add Exam.<br>  -->
		</div>
		<jsp:include page="footer.jsp" />
	</div>
</body>
</html>